﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SO
{
    class CurrentConditionDisplay : Observer, DisplayElement
    {
        private float temperature;
        private float humidity;

        // 保留一个联系方式，电话.
        // 可以更换收听者
        private Subject weatherData;

        public CurrentConditionDisplay(Subject weatherData)
        {
            // 保留发布者的信息
            this.weatherData = weatherData;

            // 调用发布者的函数 注册
            weatherData.registerObserver(this);
        }

        public void update(float temperature, float humidity, float pressure)
        {
            this.temperature = temperature;
            this.humidity = humidity;

            display();
        }

        public void display()
        {
            Console.WriteLine("Current conditions: {0}  F degrees and {1} %humidity"
                                , temperature, humidity);
        }
    }
}
